﻿using System;
using System.Collections.Generic;
using System.Text;

namespace AttributeDoem
{
    /// <summary>
    /// 范围特性
    /// </summary>
    public class ExtentAttribute : BaseVerifyAttribute
    {
        /// <summary>
        /// 规定最大的范围
        /// </summary>
        public int MaxExtent { get; set; }

        public ExtentAttribute(int maxExtent)
        {
            this.MaxExtent = maxExtent;
        }

        /// <summary>
        /// 显示父类方法
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public override bool GetVerifyInfo(object value)
        {
            if (value == null)
            {
                throw new Exception("空指针");
            }
            return Convert.ToDecimal(value) <= MaxExtent;
        }
    }
}
